package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	import org.flashIso.engine.base.IsoRoom;
	import org.flashIso.engine.core.Point2D;
	import org.flashIso.engine.objects.IsoObject;
	import org.flashIso.engine.objects.IsoTile;
	import org.flashIso.factory.IsoFactory;
	
	public class Demos extends Sprite
	{
		[Embed(mimeType="application/octet-stream", source="demo.isf")]
		public var data:Class;
		
		private var factory:IsoFactory;
		private var room:IsoRoom
		private var avatar:IsoObject
		public function Demos()
		{
			factory = new IsoFactory(new data());
			room = factory.getRoomById("room");
			room.x = stage.stageWidth / 2;
			room.y = stage.stageHeight;
			//room.map.drawGrid = false;
			avatar = room.map.getChildByName("avatar") as IsoObject;
			
			addChild(room);
			
			room.addEventListener(MouseEvent.CLICK,roomClickHandler, false, 0, true); 
		}
		
		private function roomClickHandler(e:MouseEvent) : void {
//			trace(e.target);
//			if (e.target is IsoTile) 
			{
				avatar.position = room.map.perspective.get3DCoordinates(new Point2D(room.map.mouseX, room.map.mouseY));
			}
		}
	}
}